/* enum */
import FormStyle, { FormStyleFontSizeEnum } from '@model/form/FormStyle'
/* model */
import { FormStyleFont } from '@model/form/FormStyle'
/* props */
import { FormStyleFontProps } from '@src/component/form/components/FormStyle/FormStyleFont.tsx'
/* vue */
import { reactive, toRefs, ToRefs } from 'vue'

const defaultFormStyleFontValue = {
  isBold: false,
  fontSize: FormStyleFontSizeEnum.Twelve
}

/**
 * @description 表单样式字体值
 * @param {FormStyleFontProps} props 属性列表
 * @return {ComputedRef<FormStyleFont>}
 */
export function useFormStyleFontValue(props: FormStyleFontProps): ToRefs<FormStyleFont> {
  const formStyleFontValue: ToRefs<FormStyleFont> = toRefs(reactive(props.value || defaultFormStyleFontValue)) as ToRefs<FormStyleFont>
  // 是否加粗
  const isBold: boolean = Boolean(formStyleFontValue?.isBold.value)
  
  return toRefs(reactive({
    fontSize: formStyleFontValue?.fontSize.value ? formStyleFontValue.fontSize.value : FormStyleFontSizeEnum.Twelve,
    // 是否加粗
    isBold
  }))
}
